home *** CD-ROM | disk | FTP | other *** search
- Path: in-news.erinet.com!usenet
- From: timb@erinet.com (Tim Berens)
- Newsgroups: comp.lang.c
- Subject: Re: Settle a bet please
- Date: Mon, 01 Apr 1996 22:37:36 GMT
- Organization: EriNet Online 513 436-9915
- Message-ID: <4jp8li$ue@eri2.erinet.com>
- References: <4jfopb$o9n@news1.sympatico.ca> <4jh8rtINNosd@mayne.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: edlp177.erinet.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
-
- >In article <4jfopb$o9n@news1.sympatico.ca>,
- >Gisele Swinson <gisele.swinson@sympatico.ca> wrote:
- >>In C language, how do they calculate the length of an array.
- >>
- >>example
- >>
- >>To declare a string "My Name"
- >>
- >>is it char name[7] = "My Name"
- >>or
- >>is it chat Name[8] = "My Name"
- >>
- >>There is a battle in my class whether to include the NULL in the
- >>array size.
-
- >It's a null character, not the NULL pointer.
-
- >>I would appreciate any input you might have.
-
- >The proper way is to leave the size out unless you will be writing some other
- >string into the same field.
-
- >char name[] = "My Name";
-
- Here's an interesting way to decide for yourselves:
-
- main()
- {
- printf("size is: %d",sizeof("My Name"));
- }
-
- This will display how many bytes your compiler thinks should be
- allocated for "My Name"
-
- Tim
-
-
-
-